package org.ssp.base;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.ssp.dao.UserDao;
import org.ssp.impl.UserImpl;

/**
 * 定时任务线程【没有共享数据，不存在同步问题】
 * 
 *  主线程向子线程传值：通过构造器传递
 *  
 *  子线程向主线程传值：
 *  
 * @author susp
 *
 */
public class TimerMessageThread implements Runnable{
	private int id;//备注信息的id
	private Date datetime;//消息提醒时间
	public TimerMessageThread(int id,Date datetime){
		this.id=id;
		this.datetime=datetime;
	}
	@Override
	public void run() {
		long time1=new Date().getTime();
		long time2=datetime.getTime();
		long sleeptime=(time2-time1);
		System.out.println(time1);
		System.out.println(time2);
		System.out.println(sleeptime);
		try {
			Thread.currentThread().sleep(sleeptime);
			System.err.println("in.....");
			UserDao ud=new UserImpl();
			ud.setDateTime(id, datetime);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
